//引入vue
import Vue from 'vue'
//引入路由
import VueRouter from 'vue-router'

//引入组件
import Login from '../views/Login'
import Main from '../views/Main'
import NotFound from "../NotFound";
import Canpin from "../views/Canpin";
import Register from "../views/Register";
import Order from "../views/Order"
import Staff from "../views/Staff"
import Coupon from "../views/Coupon";
import User from "../views/User";

//使用路由
Vue.use(VueRouter)

const routes = [
    //重定向
    {
        path: '/',
        redirect: '/login',
        component:Login
    },
    //登陆页面
    {
        path: '/login',
        name: 'login',
        component:Login
    },
    //注册页面
    {
        path: '/register',
        name: 'register',
        component:Register
    },
    {
        path:'/main',
        name:'main',
        component: Main,
        //嵌套路由
        children:[
            {
                path: '/',
                redirect: '/main/canpin',
                component:Canpin
            },
            {
                path: '/main/canpin',
                name:'canpin',
                component: Canpin
            },
            {
                path: '/main/order',
                name:'order',
                component: Order
            },
            {
                path: '/main/staff',
                name:'staff',
                component: Staff
            },
            {
                path: '/main/coupon',
                name:'coupon',
                component: Coupon
            },
            {
                path: '/main/user',
                name:'user',
                component: User
            },
        ]
    },
    {
        path:"*",
        component:NotFound,
    }
]

const router = new VueRouter({
    routes
})
export default router
